
<template name="memberTable">
    <el-table
            :data="memberList"
            style="width: 100%"
            :row-style="{cursor:'pointer'}"
            row-key="id"
			:height="getWinHeight"
            border
            highlight-current-row
            :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
        <el-table-column
                prop="id"
                align="center"
                label="ID"
        >
        </el-table-column>
        <el-table-column
                prop="user_content.nickname"
                align="center"
                label="用户昵称"
        >
        </el-table-column>
        <el-table-column
                prop="shop_name"
                align="center"
                label="店名"
        >
        </el-table-column>
        <el-table-column
                align="center"
                prop="status"
                label="会员状态"
        >
            <template slot-scope="scope">
                <span v-if="scope.row.status == 1">正常</span>
                <span v-if="scope.row.status == 0">待审核</span>
                <span v-if="scope.row.status == 2">未通过审核</span>
            </template>
        </el-table-column>

        <el-table-column
                prop="phone"
                align="center"
                label="会员电话"
                width="100">
        </el-table-column>
        <el-table-column
                prop="all_price"
                align="center"
                label="收益总额"
                width="100">
        </el-table-column>
        <!--<el-table-column-->
        <!--prop="buy_now_num"-->
        <!--align="center"-->
        <!--label="在售商品"-->
        <!--width="100">-->
        <!--</el-table-column>-->
        <el-table-column
                label="操作"
                align="center"
                width="250">
            <template slot-scope="scope">
            <el-button
            size="mini"
            v-if="scope.row.status == 0"
            @click="handleCheck(scope.$index, scope.row)">审核</el-button>
            <el-button
				size="mini"
				@click="toOrderList(scope.$index, scope.row)">查看订单</el-button>
            <!--<el-button
			size="mini"
            @click="handleDelete(scope.$index, scope.row)">删除</el-button>-->
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
    export default {
        name: "memberTable",
        props: ['memberList'],
        data(){
            return{
            }
        },
		computed:{
			getWinHeight(){
				let winHeight = document.body.clientHeight;
				return winHeight - 290
			}
		},
        methods: {
            handleSee(index,row){
                console.log(index, row);
                this.$router.push({
                    path: '/newBanner',
                    query: {
                        type: 4,
                        list: row
                    }
                })
            },
            handleCheck(index,row){
                console.log(index, row);
                this.$confirm('请选择是否通过该用户申请成为会员？','审核',{
                    distinguishCancelAndClose: true,
                    confirmButtonText:'通过',
                    cancelButtonText:'拒绝',
                    type:'info'
                }).then(()=>{
                    this.memberCheck(row.id,1)
                }).catch(action=>{
                    console.log(action);
                    if(action === 'cancel'){
                        this.memberCheck(row.id,2)
                    }else{
                        this.$message.info('取消审核')
                    }
                })
            },
			toOrderList(index,row){
				console.log(index,row)
				this.$router.push({
					path:'/supplier_order',
					query:{
						fx_id:row.id
					}
				})
			},
            handleDelete(index, row) {
                console.log(index, row);
                this.$confirm('此操作将永久删除该banner, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.operationBanner(row)
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            async memberCheck(id,status){
                  let res = await this.$Http.memberCheck({
                        id:id,
                        status:status
                  })
                    console.log(res);
                  if(res.code == 200){
                      if(status == 1){
                          this.$message.success('通过审核')
                          this.$emit('refreshTableFun')
                      }else if(status == 2){
                          this.$message.warning('拒绝')
                      }

                  }
            },
            async operationBanner(list){
                let res = await this.$Http.operationBanner({
                    type: 3,
                    id: list.id
                })
                console.log(res)
                if(res.code == 1){
                    this.$message({
                        type: 'success',
                        message: '此banner删除成功!'
                    });
                }
                this.$emit('refreshTableFun')
            }
        }
    }
</script>

<style scoped>

</style>
